package com.yc.nfc;

import java.math.BigInteger;
import java.util.Date;

/**
 * Created by Administrator on 2016-07-11.
 */
public class CardInfo {
    private byte[] CardID = new byte[4];            //物理卡号

    //第1扇区
    private int CardSerial;            //卡流水
    private int CardType;                //卡类
    private byte[] UserPasswordBCD = new byte[3];    //超额密码
    private byte[] CardStopDateBCD = new byte[4];    //卡有效期
    private int TotalRechargeTimes;    //充卡次数
    private byte[] JobNumber = new byte[8];            //员工编号
    private int Balance;                //卡余
    private int SpendMoney;            //消费额
    private byte[] SpendDateBCD = new byte[4];        //消费日期
    private byte[] SpendTimerBCD = new byte[3];        //消费时间
    private short SpendTimes;            //消费次数
    private int DaySpendMoney;            //当日消费累计额

    //第2扇区
    private byte[] JobNumberAscii = new byte[8];    //员工编号
    private byte[] UserNameGb2312 = new byte[8];    //用户姓名
    private byte[] CardNameAscii = new byte[16];    //卡名称("员工卡""临时卡""1类卡")


    public String getCardID() {
        String hex = Convert.ByteArrToHex(CardID, null);
        BigInteger id = new BigInteger(hex, 16);
        return String.valueOf(id.longValue());
    }

    public void setCardID(byte[] cardID) {
        CardID = cardID;
    }

    public double getBalance() {
        return Balance * 0.01;
    }


    public void recharge(int money) {
        Balance += money * 100;
        byte[] date = Convert.Date2BCD(new Date());
        SpendDateBCD[0] = date[0];
        SpendDateBCD[1] = date[1];
        SpendDateBCD[2] = date[2];
        SpendDateBCD[3] = date[3];
        SpendTimerBCD[0] = date[4];
        SpendTimerBCD[1] = date[5];
        SpendTimerBCD[2] = date[6];
    }

    public int getSpendMoney() {
        return SpendMoney;
    }

    public void setSpendMoney(int spendMoney) {
        SpendMoney = spendMoney;
    }

    public int getCardSerial() {
        return CardSerial;
    }

    public void setCardSerial(int cardSerial) {
        CardSerial = cardSerial;
    }

    public int getCardType() {
        return CardType;
    }

    public void setCardType(int cardType) {
        CardType = cardType;
    }

    public byte[] getUserPasswordBCD() {
        return UserPasswordBCD;
    }

    public void setUserPasswordBCD(byte[] userPasswordBCD) {
        UserPasswordBCD = userPasswordBCD;
    }

    public byte[] getCardStopDateBCD() {
        return CardStopDateBCD;
    }

    public void setCardStopDateBCD(byte[] cardStopDateBCD) {
        CardStopDateBCD = cardStopDateBCD;
    }

    public int getTotalRechargeTimes() {
        return TotalRechargeTimes;
    }

    public void setTotalRechargeTimes(int totalRechargeTimes) {
        TotalRechargeTimes = totalRechargeTimes;
    }

    public byte[] getJobNumber() {
        return JobNumber;
    }

    public void setJobNumber(byte[] jobNumber) {
        JobNumber = jobNumber;
    }

    public void setBalance(int balance) {
        Balance = balance;
    }

    public byte[] getSpendDateBCD() {
        return SpendDateBCD;
    }

    public void setSpendDateBCD(byte[] spendDateBCD) {
        SpendDateBCD = spendDateBCD;
    }

    public byte[] getSpendTimerBCD() {
        return SpendTimerBCD;
    }

    public void setSpendTimerBCD(byte[] spendTimerBCD) {
        SpendTimerBCD = spendTimerBCD;
    }

    public short getSpendTimes() {
        return SpendTimes;
    }

    public void setSpendTimes(short spendTimes) {
        SpendTimes = spendTimes;
    }

    public int getDaySpendMoney() {
        return DaySpendMoney;
    }

    public void setDaySpendMoney(int daySpendMoney) {
        DaySpendMoney = daySpendMoney;
    }

    public byte[] getJobNumberAscii() {
        return JobNumberAscii;
    }

    public void setJobNumberAscii(byte[] jobNumberAscii) {
        JobNumberAscii = jobNumberAscii;
    }


    public byte[] getUserNameGb2312() {
        return UserNameGb2312;
    }

    public void setUserNameGb2312(byte[] userNameGb2312) {
        UserNameGb2312 = userNameGb2312;
    }

    public byte[] getCardNameAscii() {
        return CardNameAscii;
    }

    public void setCardNameAscii(byte[] cardNameAscii) {
        CardNameAscii = cardNameAscii;
    }
}
